﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace PrismMetroSample.Infrastructure.Utility
{
    public static class TextBlockHelper
    {

        private static void TextResourceKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {

            var element = d as TextBlock;
            if (element != null)
            {

                element.SetResourceReference(TextBlock.TextProperty, e.NewValue);
            }
        }

        public static readonly DependencyProperty SourceResourceKeyProperty = DependencyProperty.RegisterAttached("TextResourceKey",
            typeof(object),
            typeof(TextBlock),
            new PropertyMetadata(String.Empty, TextResourceKeyChanged));

        public static void SetTextResourceKey(TextBlock element, object value)
        {

            element.SetValue(SourceResourceKeyProperty, value);
        }

        public static object GetTextResourceKey(TextBlock element)
        {

            return element.GetValue(SourceResourceKeyProperty);
        }
    }
}
